/**
 *******************************************************************************
 * @FileName  : msg.h
 * @Author    : GaoQiu
 * @CreateDate: 2020-05-18
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */

#ifndef MSG_H_
#define MSG_H_

#include "mdc.h"

/**
 * @brief  : Alloc Message buffer.
 * @param  : len       the length of buffer
 * @return : return buffer point or NULL.
 */
void *MsgAlloc(uint16_t len);

/**
 * @brief  : Free Message buffer.
 * @param  : msg      Pointer point to message buffer.
 * @return : None.
 */
void MsgFree(void *msg);

/**
 * @brief  : Enqueue Message.
 * @param  : pQueue      Pointer point to message queue.
 * @param  : handlerId   handler id.
 * @param  : pMsg        Pointer point to message buffer.
 * @return : None.
 */
void MsgEnqueue(queue_t *pQueue, MdcHandlerId_t handlerId, void *pMsg);

/**
 * @brief  : Dequeue Message.
 * @param  : pQueue      Pointer point to message queue.
 * @param  : handlerId   Pointer point to handler id.
 * @return : None.
 */
void *MsgDequeue(queue_t *pQueue, MdcHandlerId_t *handlerId);

/**
 * @brief  : push Message to queue head.
 * @param  : pQueue      Pointer point to message queue.
 * @param  : handlerId   handler id.
 * @param  : pMsg        Pointer point to message buffer.
 * @return :
 */
void MsgPush(queue_t *pQueue, MdcHandlerId_t handlerId,  void *pMsg);

/**
 * @brief  : get message from queue but don't remove message from queue.
 * @param  : pQueue      Pointer point to message queue.
 * @param  : handlerId   handler id.
 * @return :
 */
void *MsgGet(queue_t *pQueue, MdcHandlerId_t *handlerId);

#endif /* MSG_H_ */
